package com.bnlr.lrparking.appui.sharevalue.deposit;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bnlr.lrparking.R;
import com.bnlr.lrparking.base.BaseActivity;
import com.bnlr.lrparking.event.DepositSuccessEvent;
import com.bnlr.lrparking.model.DepositListM;
import com.bnlr.lrparking.constant.LrConstant;

import org.greenrobot.eventbus.EventBus;

import java.text.DecimalFormat;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 提现成功
 */
public class DepositSuccessActivity extends BaseActivity {
    private Unbinder unbinder;
    @BindView(R.id.check_next)
    TextView goNext;
    @BindView(R.id.tv_nav_title)
    TextView tvTitle;
    @BindView(R.id.tv_nav_right)
    TextView tvRight;
    @BindView(R.id.textView82)
    TextView textView;
    @BindView(R.id.rela_nav_back)
    RelativeLayout rl;
    @BindView(R.id.riqi)
    TextView tvRiqi;
    private int outMoney;
    private String date;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deposit_success);
        unbinder = ButterKnife.bind(this);
        rl.setVisibility(View.GONE);
        tvTitle.setText("结果详情");
        tvRight.setText("完成");
        Intent intent = getIntent();
        outMoney = intent.getIntExtra("out_money",0);
        textView.setText(intent.getStringExtra("bank_name"));
        date = intent.getStringExtra("deposit_time");
        tvRiqi.setText(date);
    }
    @OnClick({R.id.check_next,R.id.tv_nav_right})
    public void depositSuccessOnclick (View view) {
        switch (view.getId()) {
            case R.id.check_next:
                Intent intent = new Intent(DepositSuccessActivity.this,DepositdetailsActivity.class);
                DepositListM.DataBean dd = new DepositListM.DataBean();
                dd.setCreateTime(date);
                dd.setStatus("0");
                dd.setIncomeValue(outMoney);
                dd.setMoney("¥"+new DecimalFormat("######0.00").format(Double.valueOf(Double.parseDouble(outMoney+"")/ LrConstant.RATE_VALUE)));
                intent.putExtra("ti_detail",dd);
                startActivity(intent);
                break;
            case R.id.tv_nav_right:
                EventBus.getDefault().post(new DepositSuccessEvent());
                finish();
                break;
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }

    @Override
    public void onBackPressed() {

    }
}
